﻿' Params
'   artist (Required (unless mbid)] : The artist name
'   track (Required (unless mbid)] : The track name
'   mbid (Optional) : The musicbrainz id for the track
'   autocorrect[0|1] (Optional) : Transform misspelled artist and track names into correct artist and track names, returning the correct version instead. The corrected artist and track name will be returned in the response.
'   username (Optional) : The username for the context of the request. If supplied, the user's playcount for this track and whether they have loved the track is included in the response.
'   api_key (Required) : A Last.fm API key.
' Auth
'   This service does not require authentication. 

Public Structure TrackGetInfoResponse
    Dim track As Track
End Structure

Public Class TrackGetInfo
	Inherits BaseRequest

	Dim artist As String = ""
	Dim track As String = ""
	Dim mbid As String = ""
	Dim autocorrect As String = ""

	Public xmlresponse As XDocument = Nothing

	Public Sub New(ByVal artist As String, ByVal track As String, ByVal mbid As String, ByVal autocorrect As String)
		Me.artist = artist
		Me.track = track
		Me.mbid = mbid
		Me.autocorrect = autocorrect
	End Sub

	Public Sub sendRequest()
        ClearMembers()

        AddMember("method", "track.getInfo")
		AddMember("artist", artist, String.IsNullOrEmpty(mbid))
		AddMember("track", track, String.IsNullOrEmpty(mbid))
        AddMember("mbid", mbid, False)
        AddMember("username", My.Settings.user_name, False)
        AddMember("autocorrect", autocorrect, False)
		AddMember("api_key", My.Settings.api_key, False)

		xmlresponse = sendPOSTResponse()
	End Sub

    Public Function getResponse() As TrackGetInfoResponse
        Dim response As TrackGetInfoResponse = Nothing

        Try
            response.track = New Track(xmlresponse.<lfm>.<Track>.First)
        Catch ex As Exception
        End Try
        Return response
    End Function
End Class
